function AllReady() {
    var mstform = Ext.getCmp('CntProjBal1');
    var dgrid = Ext.getCmp('CntProjBalD1');
    var dstore = dgrid.store;

    dgrid.getStore().on('add', function () {
        updateJe()
    })
    dgrid.getStore().on('update', function (p1, record, p3, p4) {
        record.set('user_bhs', Ext.Number.from(record.get('AmtVatFc'), 0) - Ext.Number.from(record.get('user_se'), 0));
        record.set('user_sfje', Ext.Number.from(record.get('BillAmtVatFc'), 0) * Ext.Number.from(record.get('user_fkbl'), 0));
        updateJe();
    })
}

function updateMain1() {

}

function updateJe() {
    var dgrid = Ext.getCmp('CntProjBalD1');
    var mstform = Ext.getCmp('CntProjBal1');
    var dstore = dgrid.store;
    var sum1 = 0;
    var sum2 = 0;
    var sum3 = 0;
    Ext.each(dgrid.store.data.items, function (it) {
        if (it.data.BillAmtVatFc && it.data.user_fkbl) {
            it.data.user_sfje = Ext.Number.from(it.data.BillAmtVatFc, 0) * Ext.Number.from(it.data.user_fkbl, 0)
            sum1 = sum1 + Ext.Number.from(it.data.TotalParamAmtAndThis, 0)
            sum2 = sum2 + Ext.Number.from(it.data.user_sfje, 0)
            sum3 = sum3 + Ext.Number.from(it.data.AmtVatFc, 0)
        }
    })
    dgrid.getView().refresh();

    mstform.getItem('PayApplyAmtVatFc').setValue(sum1);
    mstform.getItem('ShouldAmtVatFc').setValue(sum2);
    mstform.getItem('user_sumysyf').setValue(sum3);
}
